package cn.watson.basic.config;

import cn.watson.basic.interceptor.LoginInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
* @Description: 登录拦截器配置类
* @Author: ZhangRui
* @Version: 1.0
* @Date:  2022/7/8 13:15
*/
@Configuration // 表示当前类是配置类
public class LoginConfig implements WebMvcConfigurer {

    @Autowired // 注入登录拦截器
    private LoginInterceptor loginInterceptor;

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(loginInterceptor) // 指定我们自己的登录拦截器
                .addPathPatterns("/**") // 设置拦截所有
                .excludePathPatterns("/login/**") // 设置放行路径端口
                .excludePathPatterns("/fastDfs/**")
                .excludePathPatterns("/verifyCode/**")
                .excludePathPatterns("/shop/settlement")
                .excludePathPatterns("/user/register/**");
    }

}
